package com.demo.wrapper.interfaces;

import com.demo.wrapper.function.IGetter;
import com.demo.wrapper.enums.OperatorEnum;

import java.util.Collection;

/**
 * 查询接口，支持lambda表达式
 *
 * @param <Wrapper>    条件拼接类，需继承Query接口
 * @param <DO>      文档实体类
 * @author 19242
 */
public interface IEsLambdaQueryWrapper<Wrapper extends IEsLambdaQueryWrapper<Wrapper, DO>, DO>
        extends IEsQueryWrapper<Wrapper>, ILambdaWrapper<Wrapper, DO> {

    default Wrapper eq(IGetter<DO> getter, Object val) {
        return eq(findField(getter), val);
    }

    default Wrapper eq(IGetter<DO> getter, Object val, float boost) {
        return eq(findField(getter), val, boost);
    }

    default Wrapper in(IGetter<DO> getter, Collection<?> val) {
        return in(findField(getter), val);
    }

    default Wrapper in(IGetter<DO> getter, Collection<?> val, float boost) {
        return in(findField(getter), val, boost);
    }

    default Wrapper match(IGetter<DO> getter, Object val) {
        return match(findField(getter), val);
    }

    default Wrapper match(IGetter<DO> getter, Object val, float boost, OperatorEnum operator) {
        return match(findField(getter), val, boost, operator);
    }

    default Wrapper matchPhrase(IGetter<DO> getter, Object val) {
        return matchPhrase(findField(getter), val);
    }

    default Wrapper matchPhrase(IGetter<DO> getter, Object val, float boost) {
        return matchPhrase(findField(getter), val, boost);
    }

    default Wrapper matchPhrasePrefix(IGetter<DO> getter, Object val) {
        return matchPhrasePrefix(findField(getter), val);
    }

    default Wrapper matchPhrasePrefix(IGetter<DO> getter, Object val, float boost) {
        return matchPhrasePrefix(findField(getter), val, boost);
    }

    default Wrapper matchPhrasePrefix(IGetter<DO> getter, Object val, int maxExpansions) {
        return matchPhrasePrefix(findField(getter), val, maxExpansions);
    }

    default Wrapper matchPhrasePrefix(IGetter<DO> getter, Object val, float boost, int maxExpansions) {
        return matchPhrasePrefix(findField(getter), val, boost, maxExpansions);
    }

    default Wrapper multiMatch(Object val, IGetter<DO>... getters) {
        return multiMatch(val, findFields(getters));
    }

    default Wrapper multiMatch(Object val, float boost, IGetter<DO>... getters) {
        return multiMatch(val, boost, findFields(getters));
    }

    default Wrapper multiMatch(Object val, int minimumShouldMatch, IGetter<DO>... getters) {
        return multiMatch(val, minimumShouldMatch, findFields(getters));
    }

    default Wrapper multiMatch(Object val, OperatorEnum operator, IGetter<DO>... getters) {
        return multiMatch(val, operator, findFields(getters));
    }

    default Wrapper multiMatch(Object val, float boost, int minimumShouldMatch, IGetter<DO>... getters) {
        return multiMatch(val, boost, minimumShouldMatch, findFields(getters));
    }

    default Wrapper multiMatch(Object val, float boost, OperatorEnum operator, IGetter<DO>... getters) {
        return multiMatch(val, boost, operator, findFields(getters));
    }

    default Wrapper multiMatch(Object val, OperatorEnum operator, int minimumShouldMatch, IGetter<DO>... getters) {
        return multiMatch(val, operator, minimumShouldMatch, findFields(getters));
    }

    default Wrapper multiMatch(Object val, float boost, OperatorEnum operator, int minimumShouldMatch, IGetter<DO>... getters) {
        return multiMatch(val, boost, operator, minimumShouldMatch, findFields(getters));
    }

    default Wrapper gt(IGetter<DO> getter, Object val) {
        return gt(findField(getter), val);
    }

    default Wrapper gt(IGetter<DO> getter, Object val, float boost) {
        return gt(findField(getter), val, boost);
    }

    default Wrapper ge(IGetter<DO> getter, Object val) {
        return ge(findField(getter), val);
    }

    default Wrapper ge(IGetter<DO> getter, Object val, float boost) {
        return ge(findField(getter), val, boost);
    }

    default Wrapper lt(IGetter<DO> getter, Object val) {
        return lt(findField(getter), val);
    }

    default Wrapper lt(IGetter<DO> getter, Object val, float boost) {
        return lt(findField(getter), val);
    }

    default Wrapper le(IGetter<DO> getter, Object val) {
        return le(findField(getter), val);
    }

    default Wrapper le(IGetter<DO> getter, Object val, float boost) {
        return le(findField(getter), val, boost);
    }

    default Wrapper between(IGetter<DO> getter, Object ge, Object le) {
        return between(findField(getter), ge, le);
    }

    default Wrapper between(IGetter<DO> getter, Object ge, Object le, float boost) {
        return between(findField(getter), ge, le, boost);
    }

    default Wrapper like(IGetter<DO> getter, Object val) {
        return like(findField(getter), val);
    }

    default Wrapper like(IGetter<DO> getter, Object val, float boost) {
        return like(findField(getter), val, boost);
    }

    default Wrapper like(IGetter<DO> getter, Object... val) {
        return like(findField(getter), val);
    }

    default Wrapper like(IGetter<DO> getter, float boost, Object... val) {
        return like(findField(getter), boost, val);
    }

    default Wrapper exists(IGetter<DO> getter) {
        return exists(findField(getter));
    }

    default Wrapper exists(IGetter<DO> getter, float boost) {
        return exists(findField(getter), boost);
    }
}
